﻿<?php

session_start();
if(empty($_SESSION['username'])||($_SESSION['user_category']!=2))
{
	echo "<script language=JavaScript>alert('您无权访问该页面!'); window.location='index.php';</script>";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>

<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>教师带班成绩查询</title>
<meta name="author" content="Codrops" />
<!-- jquery js -->
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script type="text/javascript"  src="js/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"/>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<!-- end -->
<!-- 以下部分是menu需要的css 和js -->

<script type='text/javascript' src='js/jquery.hoverIntent.minified.js'></script>
<script type='text/javascript' src='js/jquery.dcmegamenu.1.3.3.js'></script>
<!-- end  -->
<link rel="shortcut icon" href="../favicon.ico">
<link rel='stylesheet' type='text/css' href='css/jquery.kwicks.css' />
<!-- local page css -->
<link rel="stylesheet" type="text/css" href="css/jiemian.css"/>


<script src="js/modernizr.custom.63321.js"></script>


<!--[if lte IE 7]><style>.main{display:none;} .support-note .note-ie{display:block;}</style>
<![endif]-->
<!-- 放到head.php中
 <script type="text/javascript">
 $(document).ready(function($){
	 $('#mega-menu-9').dcMegaMenu({
			rowItems: '3',
			speed: 'fast',
			effect: 'fade'
		});
 });
 </script>
   -->
 <!--  取消tooltip 
 <script>

$(function() {
$( document ).tooltip();
//mega menu codes:

});
</script>

<style>
label {
display: inline-block;
width: 5em;
}
</style>
-->
<!-- 
<style type='text/css'>
			.kwicks {
				width: 515px;
				height: 100px;
			}
			.kwicks > a {
				width: 125px;
				height: 100px;
				/* overridden by kwicks but good for when JavaScript is disabled */
				margin-left: 5px;
				float: left;
			}

			#panel-1 { background-color: #53b388; }
			#panel-2 { background-color: #5a69a9; }
			#panel-3 { background-color: #c26468; }
			#panel-4 { background-color: #bf7cc7; }
		</style>
		 -->
</head>
<body>



<div class="container">
<div class="nav_header">
	
	<?php  include 'teacher_head.php';
	include 'common.php';
include 'conn.php';
?>
	<!--  white menu 部分 -->
	

	<!-- end white menu -->
	<!--  原定的menu功能，暂时删除 
<div class='kwicks kwicks-horizontal'>
			<a href='#' id='panel-1' title="首页:回到成绩管理系统首页"></a>
			<a href='#' id='panel-2' title="关于:获取关于土塘中学成绩管理系统的信息"></a>
			<a href='#' id='panel-3' title="联系我们:联系管理员"></a>
			<a href='#' id='panel-4' title="退出:退出成绩管理系统"></a>
		</div>
	-->
		</div>
		
<div class="main_cj_content">	

<p class="welcome"><?php echo $_SESSION['username']; ?>老师,欢迎您,以下是您班级的历次考试信息:</p><hr>
<br />
<br />

<?php 
$class_exe="select class from users where id=".$_SESSION['userid'];
$rs1=mysql_query($class_exe);
$row=mysql_fetch_array($rs1);
$class_info=$row['class'] or die ("请确认您的班级信息!");

$exam_exe="SELECT distinct exam_id,exam_date from grades where userid in (select id from users where class=".$class_info." and user_category=1 ) order by exam_id ";
$rs2=mysql_query($exam_exe);
while($row2=mysql_fetch_array($rs2))
{
	$exam_id=$row2['exam_id'];
	$exam_date=$row2['exam_date'];
	//echo $exam_id;
	$grades_exe="SELECT t1.sx,t1.yw,t1.yy,t1.wl,t1.hx,t1.sw,t1.ls,t1.zz,t1.dl,
		(coalesce(t1.sx,0)+coalesce(t1.yw,0)+coalesce(t1.yy,0)+coalesce(wl,0)
		+coalesce(hx,0)+coalesce(sw,0)+coalesce(ls,0)+coalesce(dl,0)+coalesce(zz,0)) 
		as sumscore,t2.realname  FROM myphpcj.grades as t1 ,users as t2 where  t1.userid=t2.id and exam_id=".$exam_id." order by sumscore desc";
	$rs=mysql_query($grades_exe);
	echo "<fieldset><legend>".$exam_date."</legend><table>";
	echo "<tr><td>姓名</td><td>数学</td><td>英语</td><td>语文</td><td>物理
	</td><td>化学</td><td>生物</td><td>历史</td><td>地理</td> <td>政治</td><td>总分</td><td>排名</td></tr>";
	$order=1;
	while($row3=mysql_fetch_array($rs))
	{
		
		$sx=$row3['sx'];
		$yw=$row3['yw'];
		$yy=$row3['yy'];
		$wl=$row3['wl'];
		$hx=$row3['hx'];
		$realname=$row3['realname'];
		$sw=$row3['sw'];
		$ls=$row3['ls'];
		$dl=$row3['dl'];
		$zz=$row3['zz'];
		$sumscore=$row3['sumscore'];
		echo "
		<tr><td>".$realname."</td><td>".$sx."</td><td>".$yw."</td><td>".$yw."</td><td>".$wl."</td><td>".$hx."</td><td>".$sw."</td><td>".$ls."</td><td>".$dl."</td><td>".$zz."</td><td>".$sumscore."</td><td>".$order."</td></tr>";
		$order=$order+1;
	}
	echo "</table></fieldset><br /><br /><br />";
}
?>

	</div>
	
	</div>
	
		

<!-- 取消方形menu 
		<script src='js/jquery.kwicks.js' type='text/javascript'></script>
		
		<script type='text/javascript'>
			$(function() {
				$('.kwicks').kwicks({
					size: 125,
					maxSize : 250,
					spacing : 5,
					behavior: 'menu'
				});
			});
		</script>
		-->
</body>
</html>
